package com.cmict.data.bpm.dal.mysql.task;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cmict.data.framework.mybatis.core.mapper.BaseMapperX;
import com.cmict.data.bpm.dal.dataobject.task.BpmTaskExtDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

@Mapper
public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {

    default void updateByTaskId(BpmTaskExtDO entity) {
        update(entity, new LambdaQueryWrapper<BpmTaskExtDO>().eq(BpmTaskExtDO::getTaskId, entity.getTaskId()));
    }

    default List<BpmTaskExtDO> selectListByTaskIds(Collection<String> taskIds) {
        return selectList(BpmTaskExtDO::getTaskId, taskIds);
    }

    default BpmTaskExtDO selectByTaskId(String taskId) {
        return selectOne(BpmTaskExtDO::getTaskId, taskId);
    }
    @Select("${sql}")
    Long getIdByTaskIdAndProcessinstanceId(String sql);

    @Select("SELECT bt.*  FROM `bpm_task_ext` bt INNER JOIN  bpm_process_instance_ext bp ON bt.`process_instance_id` = bp.`process_instance_id` WHERE bp.`status` = 1 AND bt.`result`=1 AND bt.id  = #{remindId} ;")
    BpmTaskExtDO getBpmtaskext(Long remindId);

}
